<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px" class="menu-aside">
        <div class="logo-container">
          <img src="../assets/logo.png" alt="Logo" class="logo">
          <h1 class="title">异常检测系统</h1>
        </div>
        <el-menu
          :default-active="activeMenu"
          class="main-menu"
          router
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b">
          <el-menu-item index="/model">
            <el-icon><Monitor /></el-icon>
            <span>选择网络模型</span>
          </el-menu-item>

          <el-sub-menu index="predict">
            <template #title>
              <el-icon><DataLine /></el-icon>
              <span>预测流量</span>
            </template>
            <el-menu-item index="/train">
              <el-icon><School /></el-icon>
              <span>模型训练</span>
            </el-menu-item>
            <el-menu-item index="/predict">
              <el-icon><DataLine /></el-icon>
              <span>模型预测</span>
            </el-menu-item>
            <el-menu-item index="/display">
              <el-icon><TrendCharts /></el-icon>
              <span>预测展示</span>
            </el-menu-item>
          </el-sub-menu>

          <el-menu-item index="/detect">
            <el-icon><Warning /></el-icon>
            <span>异常检测</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-container>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
import { useRoute } from 'vue-router'
import { Monitor, DataLine, Warning, School, TrendCharts } from '@element-plus/icons-vue'

const route = useRoute()
const activeMenu = computed(() => route.path)
</script>

<style lang="scss" scoped>
.common-layout {
  height: 100vh;
  .el-container {
    height: 100%;
  }
}

.menu-aside {
  background-color: #545c64;
  height: 100vh;
  .logo-container {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    color: #fff;
    .logo {
      width: 40px;
      height: 40px;
      margin-right: 10px;
    }
    .title {
      font-size: 16px;
      margin: 0;
      white-space: nowrap;
    }
  }
  .main-menu {
    border-right: none;
  }
}

.el-main {
  padding: 20px;
  background-color: #f0f2f5;
}

.el-menu-item {
  .el-icon {
    margin-right: 10px;
  }
}

.el-sub-menu {
  .el-menu-item {
    min-width: auto;
    background-color: #434a50 !important;
    &:hover {
      background-color: #363d41 !important;
    }
    &.is-active {
      background-color: #363d41 !important;
    }
  }
}
</style> 